package com.medicinemanager.ui;

import com.medicinemanager.app.AppManager;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;

public abstract class BaseActivity extends Activity{
	protected AppManager mAppManager = null;
	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		mAppManager = AppManager.getInstance();
		mAppManager.addActivity(this);
	}
	
	public boolean onKeyDown(int keyCode, KeyEvent keyEvent){
		if(keyCode == KeyEvent.KEYCODE_BACK){
			gotoBack();
			return true;
		}
		return super.onKeyDown(keyCode, keyEvent);
	}
	
	public abstract void gotoBack();
	public abstract void gotoAhead();
	
	public void onDestory(){
		super.onDestroy();
		mAppManager.finishActivity(this);
	}
}
